package org.jeecg.modules.qyxx.service.impl;


import cn.hutool.core.date.DateUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.qyxx.entity.BgSwzbjcOrder;
import org.jeecg.modules.qyxx.mapper.BgSwzbjcOrderMapper;
import org.jeecg.modules.qyxx.service.IBgSwzbjcOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

/**
 * @Description: 税务指标监测状态
 * @Author: ZJJ
 * @Date:   2021-06-18
 * @Version: V1.0
 */
@Service
// @DS("multi-datasource1")申报
public class BgSwzbjcOrderServiceImpl extends MppServiceImpl<BgSwzbjcOrderMapper, BgSwzbjcOrder> implements IBgSwzbjcOrderService {
    @Autowired
    private BgSwzbjcOrderMapper bgSwzbjcOrderMapper;

    @Override
    public List<BgSwzbjcOrder> selectList(List<String> nsrsbh, String ssny) {
        return bgSwzbjcOrderMapper.selectMyList(nsrsbh,ssny);
    }

    /*@Override
    public String getNewByDjxh(String djxh) {
        LambdaQueryWrapper<BgSwzbjcOrder> wrapper = Wrappers.lambdaQuery(BgSwzbjcOrder.class);
        wrapper.eq(BgSwzbjcOrder::getDjxh,djxh).orderByDesc(BgSwzbjcOrder::getSsny);
        // List<BgSwzbjcOrder> list = super.list(wrapper);
        List<BgSwzbjcOrder> list = baseMapper.listByDjxh(djxh);
        // List<BgSwzbjcOrder> list =baseMapper.selectList(wrapper);
        BgSwzbjcOrder order = list.get(0);
        try {
            Date date = DateUtils.parseDate(order.getSsny(), "yyyy-MM-dd HH:mm:ss");
            String year = org.jeecg.modules.qyxx.util.DateUtils.getInstance().getYearToStr(date);
            return year;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return org.jeecg.modules.qyxx.util.DateUtils.getInstance().getYearToStr(new Date());
    }

    @Override
    public String getNewMonthByDjxh(String djxh) {
        *//*LambdaQueryWrapper<BgSwzbjcOrder> wrapper = Wrappers.lambdaQuery(BgSwzbjcOrder.class);
        wrapper.eq(BgSwzbjcOrder::getDjxh,djxh).orderByDesc(BgSwzbjcOrder::getSsny);*//*
        BgSwzbjcOrder order = baseMapper.listByDjxh(djxh).get(0);
        try {
            Date date = DateUtils.parseDate(order.getSsny(), "yyyy-MM-dd HH:mm:ss");
            String month = org.jeecg.modules.qyxx.util.DateUtils.getInstance().getMonthToStr(date);
            return month;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return org.jeecg.modules.qyxx.util.DateUtils.getInstance().getMonthToStr(new Date());
    }*/
}
